#include "NetToolKits.h"

IocpClient::IocpClient(int recvBufferSize){
	dwRecvBytes = 0;
	dwSentBytes = 0;
	dwFlags = 0;
	wsRecvBuff.buf = (char*)(new byte[recvBufferSize]);
	wsRecvBuff.len = recvBufferSize;
	memset(wsRecvBuff.buf, 0, wsRecvBuff.len);
	memset(&(this->overLapped_send), 0, sizeof(OVERLAPPED));
}

IocpClient::~IocpClient(){
	delete wsRecvBuff.buf;
	wsRecvBuff.len = 0;
}

YHBOOL IocpClient::connect(string ipaddr, int port){
	return false;
}

int IocpClient::sendAsync(const byte* frame, int framebegin, int len){
	this->wsSendBuff.buf = (char*)(frame+framebegin);
	this->wsSendBuff.len = len;
	return WSASend(this->connectSocket, &(this->wsSendBuff), 1, &(this->dwSentBytes), 0, &(this->overLapped_send), NULL);
}

int IocpClient::send(const byte* frame, int framebegin, int len){
	return ::send(this->connectSocket, (const char*)(frame + framebegin), len, 0);
}